#include "widget.h"
#include "ui_widget.h"

#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->pushButton,&QPushButton::clicked,[this](){
        this->setWindowTitle("切换前");
    });

    connect(ui->pushButton_3,&QPushButton::clicked,this,&Widget::slotClicked1);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_2_clicked()
{
    connect(ui->pushButton,&QPushButton::clicked,[this](){
        this->setWindowTitle("切换后");
    });
}

void Widget::slotClicked1()
{
     this->setWindowTitle("slotClicked1");
}
void Widget::slotClicked2()
{
     this->setWindowTitle("slotClicked2");
}

void Widget::on_pushButton_4_clicked()
{
    disconnect(ui->pushButton_3,&QPushButton::clicked,this,&Widget::slotClicked2);
    ui->pushButton_4->setText("switch");
    ui->pushButton_5->setText("Modify Button Connect");
    connect(ui->pushButton_3,&QPushButton::clicked,this,&Widget::slotClicked1);
}

void Widget::on_pushButton_5_clicked()
{
    disconnect(ui->pushButton_3,&QPushButton::clicked,this,&Widget::slotClicked1);
    ui->pushButton_4->setText("Modify Button Connect");
    ui->pushButton_5->setText("switch");
    connect(ui->pushButton_3,&QPushButton::clicked,this,&Widget::slotClicked2);
}
